//test
angular.module('testModule', [])
    .controller('AppCtrlTest', function ($scope, $ionicHistory, $ionicModal, $timeout) {

        $scope.backPage = function () {
            $ionicHistory.goBack(-1)
        };


        $scope.recordVideo=function(){
            var option = {
                "type": "recordVideo"
            }
            window.ReactNativeWebView.postMessage(JSON.stringify(option));
        }

        $scope.share=function(filePath){
            var option = {
                "type": "share",
                "filePath":filePath
            }
            window.ReactNativeWebView.postMessage(JSON.stringify(option));
        }

        $scope.takePhotos = function () {
            var option = {
                "type": "takePhotos"
            }
            window.ReactNativeWebView.postMessage(JSON.stringify(option));
        };

        $scope.jumpNavigation=function(){

            var option = {
                "type": "AmapNavigation"
            }
            window.ReactNativeWebView.postMessage(JSON.stringify(option));

        }

        $scope.startRecordAudio = function () {
            var option = {
                "type": "startRecordAudio"
            };
            window.ReactNativeWebView.postMessage(JSON.stringify(option));
        };
        $scope.stopRecordAudio = function () {
            var option = {
                "type": "stopRecordAudio"
            };
            window.ReactNativeWebView.postMessage(JSON.stringify(option));
        }; 
          $scope.getDeviceInfo = function () {
            var option = {
                "type": "getDeviceInfo"
            };
            window.ReactNativeWebView.postMessage(JSON.stringify(option));
        };
        $scope.geolocation = function () {
            var option = {
                "type": "geolocation"
            };
            window.ReactNativeWebView.postMessage(JSON.stringify(option));
        };

        $scope.uploadImage=function(filePath){
            var option = {
                "type": "uploadImage",
                "filePath":filePath
            };
            window.ReactNativeWebView.postMessage(JSON.stringify(option));
        };
        $scope.markerImage=function(filePath){
            var option = {
                "type": "markerImage",
                "text": "时间: "+Date.now(),
                "filePath":filePath
            };
            window.ReactNativeWebView.postMessage(JSON.stringify(option));
        };

        $scope.uploadFile=function(filePath){
            var option = {
                "type": "uploadFile",
                "filePath":filePath
            };
            window.ReactNativeWebView.postMessage(JSON.stringify(option));
        };


// 事件监听 ---------------------------------------------------------------------------------------------

        window.selectImageEvent = function (event) {
            $scope.imgPathUri = event;
            $scope.imgPathUriFile = event;
            $scope.$apply();
        };

        window.uploadFileSuccess=function(event){
            $scope.imgUrl = event;
            $scope.imgUrlFile = "http://androidimg"+event;
            $scope.$apply();
        }

       window.videoPath=function(event){
            $scope.fileUrl = event;
            $scope.$apply();
        }


        window.geolocation = function (event) {
            $scope.locationMsg = event;
            $scope.$apply();
        }
        window.speechRecognition = function (event) {
            $scope.messageData = event;
            $scope.$apply();
         }
      window.deviceInfo = function (event) {
            $scope.devInfo = event;
            $scope.$apply();
         }
         window.netinfo = function (event) {
            $scope.netinfo = event;
            $scope.$apply();
         }


    });

